import * as request from '../constant/fetch-request'
import HTTP_CODE from '../constant/http-code'
import {message} from 'antd'
export const getQuizSuggestions = () => {
  return dispatch => {
    (async () => {
      const res = await request.get(`./api/v3/quizzes/suggestions`)
      if (res.status === HTTP_CODE.OK) {
        dispatch({
          type: 'GET_LOGIC_QUIZ_SUGGESTIONS',
          data: res.body
        })
      }
    })()
  }
}


export const markAsSolved = id => {
  return dispatch => {
    (async () => {
      const res = await request.update(`./api/v3/quizzes/suggestions/${id}`)
      if (res.status === HTTP_CODE.NO_CONTENT) {
        message.success('标注成功')
        dispatch(getQuizSuggestions())
      }
    })()
  }
}

